﻿using System;
using System.Collections.Generic;

using System.Text;
using wrzy.utll;
using System.Threading;
using System.Data.SqlClient;
using System.Data.OracleClient;
namespace wrzy
{
    class zyDriver
    {
        string lsql;
        /// <summary>
        /// 发送系统启动信号
        /// </summary>
        public void zyStart()
        {

            sqlServer drop = new sqlServer();
            drop.ExecuteSql("update zystatus set Start=1");
            Thread.Sleep(2000);
            drop.ExecuteSql("update zystatus set Start=0");
        }
        /// <summary>
        /// 发送系统停止信号
        /// </summary>
        public void zyStop()
        {
            sqlServer drop = new sqlServer();
            drop.ExecuteSql("update zystatus set Stop=1");
            Thread.Sleep(2000);
            drop.ExecuteSql("update zystatus set Stop=0");
        }
        #region
        /// <summary>
        /// 查看制样系统是否准备好了
        /// </summary>
        /// <returns>返回制样系统状态</returns>
        public Boolean zyprocStatus()
        {
            int status;
            sqlServer tpData = new sqlServer();
            SqlDataReader TpReader = tpData.ExecuteReader("select zyReady from zyprocStatus ");
            TpReader.Read();
            status = (int)TpReader.GetValue(0);
            TpReader.Close();
            if (status == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        #endregion

        #region
        /// <summary>
        /// 返回当前的制样编码
        /// </summary>
        /// <returns></returns>
        public string zySamcode()
        {
            string s;
            oracleDatabase data = new oracleDatabase();
            OracleDataReader myreader = data.ExecuteReader(@"select value from t_dict where name='制样用采样编码' and parentid=(select id from t_dict where name='系统参数')");
            myreader.Read();
            s = myreader.GetValue(0).ToString();
            myreader.Close();
            return s;
        }
        #endregion
        #region
        /// <summary>
        /// 查看制样系统是否准备好了
        /// </summary>
        /// <returns></returns>
        
        public Boolean zyready()
        {
            sqlServer data = new sqlServer();
            SqlDataReader myreader = data.ExecuteReader(@"select zyready from [zyprocStatus]");
            myreader.Read();
            if (Convert.ToInt16( myreader.GetValue(0)) == 1)
            {
                return true;

            }
            else
            {
                return false; 
            }
        }
        #endregion
        #region
        /// <summary>
        /// 查看是否制样结束
        /// </summary>
        /// <returns></returns>
        public Boolean zyFin()
        {
            sqlServer data = new sqlServer();
            SqlDataReader myreader = data.ExecuteReader(@"select zyFin from [zyprocStatus]");
            myreader.Read();
            if (Convert.ToInt16(myreader.GetValue(0)) == 1)
            {
                return true;

            }
            else
            {
                return false;
            }
        }
        #endregion
    }
}
